package com.weirong.smartvault.backservice.entity_model;

import com.weirong.smartvault.common.tools.spring.context.SpringContextUtil;
import com.weirong.smartvault.dao.DeliveryLogRepository;
import com.weirong.smartvault.entity.ConfirmDetailLog;
import com.weirong.smartvault.entity.DeliveryLog;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: kfeb4
 * Date: 2017/12/27
 * Time: 11:25
 */
public class ConfirmDetailLogModel {
    ConfirmDetailLog log;
    DeliveryLogRepository deliveryLogRepository;
    List<MoneyLogModel> requestDetail = null;
    List<MoneyLogModel> deliveryDetail = null;
    DeliveryLogModel deliveryLogModel = null;
    public Integer getId(){
        return log.getId();
    }
    public ConfirmDetailLogModel(ConfirmDetailLog log) throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
        this.log = log;
        this.deliveryLogRepository = SpringContextUtil.getBean(DeliveryLogRepository.class);
        Integer id = log.getDeliveryId();
        DeliveryLog deliveryLog = deliveryLogRepository.findOne(id);
        deliveryLogModel = new DeliveryLogModel(deliveryLog);
        requestDetail = deliveryLogModel.getRequestDetail();
        deliveryDetail = deliveryLogModel.getDeliveryDetail();
    }

    public List<MoneyLogModel> getRequestDetail() throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
        return requestDetail;
    }

    public List<MoneyLogModel> getDeliveryDetail() {
        return deliveryDetail;
    }

    public boolean getConfirmResultBoolean() {
        return getConfirmResult().equals("success");
    }

    public String getConfirmResult() {
        return log.getConfirmResult();
    }

    public String getFailReson() {
        return log.getFailReason();
    }
}
